<template>
  <view>
    <view class="top">
      <view class="top-more">
        <image v-if="hasMore" class="recommend-item-img" mode="widthFix" :src="data.imageLinks" alt="" @click="more(data)"></image>
      </view>
      <view class="top-add" @click="addTeacher">
          <img class="top-img" src="./img/add.png" alt="">
          <view>添加老师</view>
      </view>
      <teacher-modal ref="cus"></teacher-modal>
    </view>
    <view class="top-height"></view>
  </view>
</template>
<script>
import { appProductId } from "@/http/env.js";
import { getProductConfigApi } from "@/http/api.js";
export default {
  name: 'TopBanner',
  data() {
    return {
      positionId: 1,
      hasMore: false,
      date: {}
    }
  },
  mounted() {
    // 获取产品线配置
    getProductConfigApi({
      parentId: appProductId,
      positionType: this.positionId
    }).then(res => {
      if (res.code === 200 && res.data.length != 0) {
        this.hasMore = true;
        this.data = res.data[0];
      }else{
        this.hasMore = false;
      }
    })
  },
  methods: {
    more() {
      let sub = uni.getStorageSync('sub');
      let origin = window.location.origin;
      window.location.href = `${origin}/uniteby/?sub=${sub}`;
    },
    addTeacher() {
      this.$refs.cus.open()
    }
  }
}
</script>
<style lang="scss" scoped>
.top-height {
  height: 92rpx;
}
.top {
  height: 92rpx;
  position: fixed;
  width: 100%;
  z-index: 999;
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  background-color: #ffffff;
  padding: 20rpx 20rpx;
  .top-more {
    width: 180rpx;
    height: 48rpx;
    border-radius: 24rpx;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .top-add {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .top-img {
    width: 36rpx;
    height: 36rpx;
  }
}
</style>